/*
 * @(#)ApplicationException.java 1.0.0 27/05/2014 *
 * INTRODUCCION A APLICACIONES J2EE
 * Ing. Darwin Rodrigo Zottola Pareja
 * rodrigozeta@gmail.com - twitter @Monozeta
 */
package com.unt.javawebunt.exception;

/**
 * @author rzottola
 * @version 1.0
 * @since 27/05/2014
 */
public class ApplicationException extends Exception {

	/**
	 * serial UID
	 */
	private static final long serialVersionUID = -3070679528795167805L;

	/**
	 * mapped error number.
	 */
	private int errorNumber = 1000; // Generic error by default

	/**
	 * constructor
	 */
	public ApplicationException() {
		super();
	}

	public ApplicationException(int errorNumber) {
		super();
		this.errorNumber = errorNumber;
	}

	public ApplicationException(int errorNumber, Throwable ex) {
		super(ex);
		this.errorNumber = errorNumber;
	}

	public ApplicationException(int errorNumber, String msg) {
		super(msg);
		this.errorNumber = errorNumber;
	}

	/**
	 * constructor
	 * 
	 * @param msg
	 */
	public ApplicationException(String msg) {
		super(msg);
	}

	/**
	 * constructor
	 */
	public ApplicationException(Throwable cause) {
		super(cause);
	}

	/**
	 * constructor
	 */
	public ApplicationException(String msg, Throwable cause) {
		super(msg, cause);
	}

	/**
	 * return generic message in case that doesnt exists other.
	 */
	public String getMessage() {
		String msg = super.getMessage();

		if (msg == null || msg.equals("")) {
			return "Application General Exception - An unexpected exception has been thrown.";
		}

		return super.getMessage();
	}

	public int getErrorNumber() {
		return errorNumber;
	}
}
